from abc import abstractmethod
from collections import Sized, Iterator


class Indexable(Sized):
    __slots__ = ()

    @abstractmethod
    def __getitem__(self, index):
        raise IndexError

    @classmethod
    def __subclasshook__(cls, C):
        if cls is Indexable:
            if (any("__len__" in B.__dict__ for B in C.__mro__) and
                any("__getitem__" in B.__dict__ for B in C.__mro__)):
                return True
        return NotImplemented


class SizedIterator(Sized, Iterator):
    __slots__ = ()

    @classmethod
    def __subclasshook__(cls, C):
        if cls is SizedIterator:
            if (any("__len__" in B.__dict__ for B in C.__mro__) and
                any("__next__" in B.__dict__ for B in C.__mro__) and
                any("__iter__" in B.__dict__ for B in C.__mro__)):
                return True
        return NotImplemented
